package com.atiguigu.spring6.validator.one;

import org.springframework.validation.DataBinder;


// 通过Validator接口实现自定义校验
public class TestPerson {
    public static void main(String[] args) {
        Person person = new Person();
        person.setName("aaa");

        DataBinder dataBinder = new DataBinder(person);
        dataBinder.setValidator(new PersonValidator());
        dataBinder.validate();
        dataBinder.getBindingResult().getAllErrors().forEach(error -> System.out.println(error.getDefaultMessage()));
    }
}
